
/**
 * 
<android.widget.FrameLayout visible="true">
    <android.widget.TextView id="com.smile.gifmaker:id/common_red_packet_pop_prepare_reward_desc_view" text="主播的口令红包" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/status_text_view" text="很遗憾，本次未中奖" visible="true">
    </android.widget.TextView>
    <android.widget.TextView text="看看大家手气" visible="true">
    </android.widget.TextView>
    <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/lucky_user_recycler_view" visible="true">
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.smile.gifmaker:id/avatar_view" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.smile.gifmaker:id/user_name_text_view" text="拉***" visible="true">
            </android.widget.TextView>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content" visible="true">
                <android.view.ViewGroup visible="true">
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_count" text="4" visible="true">
                    </android.widget.TextView>
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_unit" text="快币" visible="true">
                    </android.widget.TextView>
                </android.view.ViewGroup>
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.smile.gifmaker:id/avatar_view" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.smile.gifmaker:id/user_name_text_view" text="缘***" visible="true">
            </android.widget.TextView>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content" visible="true">
                <android.view.ViewGroup visible="true">
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_count" text="3" visible="true">
                    </android.widget.TextView>
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_unit" text="快币" visible="true">
                    </android.widget.TextView>
                </android.view.ViewGroup>
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.smile.gifmaker:id/avatar_view" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.smile.gifmaker:id/user_name_text_view" text="浨***" visible="true">
            </android.widget.TextView>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content" visible="true">
                <android.view.ViewGroup visible="true">
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_count" text="2" visible="true">
                    </android.widget.TextView>
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_unit" text="快币" visible="true">
                    </android.widget.TextView>
                </android.view.ViewGroup>
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.smile.gifmaker:id/avatar_view" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.smile.gifmaker:id/user_name_text_view" text="圆***" visible="true">
            </android.widget.TextView>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content" visible="true">
                <android.view.ViewGroup visible="true">
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_count" text="2" visible="true">
                    </android.widget.TextView>
                    <android.widget.TextView id="com.smile.gifmaker:id/red_packet_cover_reward_usual_unit" text="快币" visible="true">
                    </android.widget.TextView>
                </android.view.ViewGroup>
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
    </androidx.recyclerview.widget.RecyclerView>
    <android.widget.TextView id="com.smile.gifmaker:id/common_red_packet_pop_prepare_reward_desc_view" text="主播的口令红包" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/status_text_view" text="正在开奖" visible="true">
    </android.widget.TextView>
    <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/roll_user_recycler_view" visible="true">
        <undefined >
        </undefined>
        <undefined >
        </undefined>
        <undefined >
        </undefined>
        <undefined >
        </undefined>
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.smile.gifmaker:id/avatar_view" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.smile.gifmaker:id/user_name_text_view" text="～***" visible="true">
            </android.widget.TextView>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content">
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
        <android.widget.FrameLayout visible="true">
            <undefined >
            </undefined>
            <undefined >
            </undefined>
            <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/rv_content">
            </androidx.recyclerview.widget.RecyclerView>
        </android.widget.FrameLayout>
    </androidx.recyclerview.widget.RecyclerView>
    <android.widget.ImageView id="com.smile.gifmaker:id/close_view" clickable="true" visible="true">
    </android.widget.ImageView>
</android.widget.FrameLayout>
 */


/**
 * <android.widget.FrameLayout visible="true">
    <android.widget.TextView id="com.smile.gifmaker:id/coupon_top_title" text="手慢了，补偿一张充值券" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/coupon_discount_number" text="4%" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/coupon_discount_type_text" text="返利" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/coupon_desc_text" text="充值快币赠送" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/coupon_expire_time" text="01/30 18:33后过期" visible="true">
    </android.widget.TextView>
    <android.widget.TextView id="com.smile.gifmaker:id/recharge_coupon_button" text="立即抢" clickable="true" visible="true">
    </android.widget.TextView>
</android.widget.FrameLayout>
 */

/**
 * 

<android.widget.FrameLayout visible="true">
    <android.view.ViewGroup id="com.smile.gifmaker:id/live_slide_square_side_bar_layout" clickable="true">
        <android.widget.FrameLayout id="com.smile.gifmaker:id/live_square_side_bar_layout_close_view" clickable="true">
        </android.widget.FrameLayout>
    </android.view.ViewGroup>
    <androidx.recyclerview.widget.RecyclerView id="com.smile.gifmaker:id/photo_feed_side_bar_recycler_view">
    </androidx.recyclerview.widget.RecyclerView>
    <androidx.viewpager.widget.ViewPager id="com.smile.gifmaker:id/live_slide_view_pager" visible="true">
        <android.widget.FrameLayout id="com.smile.gifmaker:id/live_play_root_container" visible="true">
            <android.widget.FrameLayout id="com.smile.gifmaker:id/live_heart_particle_container" visible="true">
            </android.widget.FrameLayout>
            <android.view.ViewGroup visible="true">
                <android.widget.ImageView id="com.smile.gifmaker:id/live_play_closed_v3_back_btn" clickable="true" visible="true">
                </android.widget.ImageView>
                <android.widget.TextView id="com.smile.gifmaker:id/live_play_closed_v3_title_text_view" text="直播已结束" visible="true">
                </android.widget.TextView>
                <android.widget.ImageView id="com.smile.gifmaker:id/live_play_closed_v3_avatar_view" clickable="true" visible="true">
                </android.widget.ImageView>
                <android.widget.ImageView id="com.smile.gifmaker:id/live_play_closed_v3_follow_btn" clickable="true" visible="true">
                </android.widget.ImageView>
                <android.widget.TextView id="com.smile.gifmaker:id/live_play_closed_v3_name_view" text="傻 六" visible="true">
                </android.widget.TextView>
                <android.widget.TextView id="com.smile.gifmaker:id/live_play_closed_redpacket_tip" text="主播的所有红包已开奖，如您已参与，请查看“快手直播”的私信" visible="true">
                </android.widget.TextView>
                <android.widget.TextView id="com.smile.gifmaker:id/live_play_closed_predict_like_text_view" text="猜你喜欢" visible="true">
                </android.widget.TextView>
            </android.view.ViewGroup>
        </android.widget.FrameLayout>
        <android.widget.FrameLayout id="com.smile.gifmaker:id/play_view_wrapper" clickable="true">
            <android.widget.FrameLayout id="com.smile.gifmaker:id/play_view" clickable="true">
            </android.widget.FrameLayout>
        </android.widget.FrameLayout>
    </androidx.viewpager.widget.ViewPager>
</android.widget.FrameLayout>
 */
/**
 * 

<android.widget.FrameLayout visible="true">
    <android.widget.LinearLayout visible="true">
        <android.widget.FrameLayout visible="true">
            <android.widget.ImageView id="com.kuaishou.nebula:id/photo" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.ImageView id="com.kuaishou.nebula:id/close" clickable="true" visible="true">
            </android.widget.ImageView>
        </android.widget.FrameLayout>
        <android.widget.LinearLayout visible="true">
            <android.widget.ImageView id="com.kuaishou.nebula:id/avatar" clickable="true" visible="true">
            </android.widget.ImageView>
            <android.widget.TextView id="com.kuaishou.nebula:id/title" text="滋全滋美汤料" visible="true">
            </android.widget.TextView>
        </android.widget.LinearLayout>
        <android.widget.Button id="com.kuaishou.nebula:id/action" text="暂未直播，去个人主页" clickable="true" visible="true">
        </android.widget.Button>
        <android.widget.TextView id="com.kuaishou.nebula:id/source" text="分享者@日游神" clickable="true" visible="true">
        </android.widget.TextView>
    </android.widget.LinearLayout>
</android.widget.FrameLayout>
 */
import { Ast } from "../ast";
import { RedOpenContext, RedOpenVisitor } from "./RedOpen";
export class RedOpenFailVisitor extends RedOpenVisitor {
    visitNode(node: Ast, ctx: RedOpenContext) {
        super.visitNode(node, ctx)
    }
    visitButton(node: Ast, ctx: RedOpenContext) {
        if (node.text === `暂未直播，去个人主页`) {
            ctx.status = 'fail'
            return;
        }
    }
    visitImageView(node: Ast, ctx: RedOpenContext) {
        if (node.id.endsWith(`close_view`) && node.clickable) {
            ctx.close = () => node.click()
        }
    }
    visitTextView(node: Ast, ctx: RedOpenContext) {
        if (node.id.endsWith(`status_text_view`) && node.text === `很遗憾，本次未中奖`) {
            ctx.status = `fail`
            return;
        }
        if (node.id.endsWith(`coupon_top_title`) && node.text === `手慢了，补偿一张充值券`) {
            ctx.status = `fail`
            return;
        }
        if (node.id.endsWith(`empty_desc_text_view`) && node.text === `很遗憾，本次任务失败`) {
            ctx.status = `fail`
            return;
        }
        if (node.id.endsWith(`live_play_closed_v3_title_text_view`) && node.text === `直播已结束`) {
            ctx.status = `fail`
            return;
        }
    }
}
